<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    /*
        1.函数名就是指向函数的指针
     */
    function sum(num1, num2) {
        return num1 + num2;
    }

    console.log(sum(10, 10))  // 20
    let anotherSum = sum;
    console.log(anotherSum(10, 10))  // 20

    sum = null
    console.log(anotherSum(10, 10))     // 20

    /*
        2.name属性
     */
    console.log('---2---')

    function foo() {
    }

    let bar = function () {
    }
    let baz = () => {
    }
    console.log(foo.name) // foo
    console.log(bar.name) // bar
    console.log(baz.name) // baz

    /*
        2.1 使用bind
     */
    function foo2() {
    }

    console.log(foo2.bind(null).name) // bound foo
    let dog = {
        years:1,
        get age(){
            return this.years;
        },
        set age(newAge){
            this.years = newAge
        }
    }
    
    let propertyDescriptor = Object.getOwnPropertyDescriptors(dog,'age')
    console.log(propertyDescriptor.get.name)  // get age
    console.log(propertyDescriptor.set.name)  // set age
    

</script>
</body>
</html>